// 项目上下文，默认可为"/"
var context = "/yonginfo/";
// 页面右上角页面导航链接
var navUl = [{name: "首页", url: ""}, {name: "作品展示", url: "project.html"}, {name: "联系我", url: "concat.html"}];
for (var i in navUl) {
    navUl[i].url = context + navUl[i].url;
}
console.log(navUl);

/**
 * 时间差
 * @param dateString 日期字符串
 * @returns {string} 返回时间差格式如 x年x月x天
 */
function timeAgo(dateString) {
    const targetDate = new Date(dateString);
    const currentDate = new Date();
    const timeDifference = currentDate - targetDate;
    const years = Math.floor(timeDifference / (1000 * 60 * 60 * 24 * 365));
    const months = Math.floor((timeDifference % (1000 * 60 * 60 * 24 * 365)) / (1000 * 60 * 60 * 24 * 30));
    const days = Math.floor((timeDifference % (1000 * 60 * 60 * 24 * 30)) / (1000 * 60 * 60 * 24));

    return `${years}年${months}月${days}天`;
}


